package com.ssoclient2.listen;
import com.ssoclient2.config.MySessionContext;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
/**
 * @author panyuanxin
 * @date 2021年06月21日 11:51
 */
@Component
public class SessionListener implements HttpSessionListener {
  private MySessionContext myc = MySessionContext.getInstance();
  @Override
  public void sessionCreated(HttpSessionEvent httpSessionEvent) {
    HttpSession session = httpSessionEvent.getSession();
    myc.addSession(session);
  }
  @Override
  public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
    HttpSession session = httpSessionEvent.getSession();
    myc.delSession(session);
  }
}
